package com.ettractions.kiosk.mediators
{
	import com.ettractions.kiosk.components.BrochureMenu;
	import com.ettractions.kiosk.events.BrochureSelectedEvent;
	import com.ettractions.kiosk.events.PreRenderBrochureEvent;
	import com.ettractions.kiosk.renderers.*;
	import com.ettractions.kiosk.vo.BrochureVO;

	import org.robotlegs.mvcs.Mediator;

	public class BrochureMenuMediator extends Mediator
	{
		[Inject]
		public var view:BrochureMenu;
		
		override public function onRegister():void
		{
			eventDispatcher.addEventListener(PreRenderBrochureEvent.PRE_RENDER_BROCHURE, handlePreRenderBrochure);			
			eventDispatcher.addEventListener(BrochureSelectedEvent.BROCHURE_SELECTED, handleBrochureEvent);
			
		}
				
		private function handlePreRenderBrochure(event:PreRenderBrochureEvent):void
		{
			//updateView(event.brochure);
		}
		
		private function handleBrochureEvent(event:BrochureSelectedEvent):void
		{
			if (event.brochure != null)
			{
				updateView(event.brochure);
			}
		}		

		private function updateView(brochure:BrochureVO):void
		{
			view.data = brochure;			
			view.ac.setItemAt({label:"ABOUT", isSpecial:brochure.specialTag}, 0);
			view.ac.setItemAt({label:"MAP & DIRECTIONS", isSpecial:brochure.specialTag}, 1);
			view.ac.setItemAt({label:"SEND TO ME", isSpecial:brochure.specialTag}, 2);
			view.ac.setItemAt({label:"BOOKING INFO", isSpecial:brochure.specialTag}, 3);
			view.ac.setItemAt({label:"SPECIALS", isSpecial:brochure.specialTag}, 4);
		}
		
	}
}